//
//  SCHotelInfoCell.m
//  shangcheng
//
//  Created by Jie Jie on 2019/7/11.
//  Copyright © 2019 张艳江. All rights reserved.
//

#import "SCHotelInfoCell.h"
#import "SCHotelNoticeView.h"


CGFloat const k_hotel_info_cell_lr_out_space = 9;
CGFloat const k_hotel_info_cell_lr_in_space = 5;
CGFloat const k_hotel_info_cell_tb_space = 11;

#define k_hotel_room_image_view_h       100
#define k_hotel_room_image_view_w       k_hotel_room_image_view_h * 134/100

#define k_hotel_evaluate_image_view_h   40


@interface SCHotelInfoCell()
/*
 * 房间
 */
@property (nonatomic , strong) UIImageView *hotel_room_image_view;
@property (nonatomic , strong) UILabel *hotel_room_name_label;
@property (nonatomic , strong) UILabel *hotel_room_info_label;
@property (nonatomic , strong) UILabel *hotel_room_remark_label;
@property (nonatomic , strong) UILabel *hotel_room_price_label;
@property (nonatomic , strong) UIButton *hotel_room_reserve_button;

/*
 * 评价
 */
@property (nonatomic , strong) UIImageView *hotel_evaluate_image_view;
@property (nonatomic , strong) UILabel *hotel_evaluate_nema_label;
@property (nonatomic , strong) UILabel *hotel_evaluate_room_label;
@property (nonatomic , strong) UILabel *hotel_evaluate_timer_label;
@property (nonatomic , strong) UILabel *hotel_evaluate_info_label;

/*
 * 酒店设置
 */

/*
 * 入住须知
 */
@property (nonatomic , strong) SCHotelNoticeView *hotel_notice_view;

/*
 * 入住须知图片
 */
@property (nonatomic , strong) UIImageView *hotel_notice_image_view;


@end

@implementation SCHotelInfoCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self=  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        if ([reuseIdentifier isEqualToString:@"SCHotelRoomViewCell"]) {
            
            [self createSCHotelRoomView];
            
        }else if ([reuseIdentifier isEqualToString:@"SCHotelEvaluateViewCell"]){
            
             [self createSCHotelEvaluateView];
            
        }else if ([reuseIdentifier isEqualToString:@"SCHotelSetViewCell"]){
            
            [self createSCHotelSeteView];
            
        }else if ([reuseIdentifier isEqualToString:@"SCHotelNoticeViewCell"]) {
            
            [self createSCHotelNoticeView];
            
        }else if ([reuseIdentifier isEqualToString:@"SCHotelNoticeImageViewCell"]) {
            
            [self createSCHotelNoticeImageView];
            
        }
       
    }
    return self;
}

/*
 * 房间
 */
-(void)createSCHotelRoomView{
    
    [self.contentView addSubview:self.hotel_room_image_view];
    [self.contentView addSubview:self.hotel_room_name_label];
    [self.contentView addSubview:self.hotel_room_info_label];
    [self.contentView addSubview:self.hotel_room_remark_label];
    [self.contentView addSubview:self.hotel_room_price_label];
    [self.contentView addSubview:self.hotel_room_reserve_button];
    
    CGFloat label_h = k_hotel_room_image_view_h * 0.2;
    
    [self.hotel_room_image_view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(k_hotel_info_cell_tb_space);
        make.height.mas_equalTo(k_hotel_room_image_view_h);
        make.width.mas_equalTo(k_hotel_room_image_view_w);
        make.left.mas_equalTo(k_hotel_info_cell_lr_out_space);
    }];
    
    [self.hotel_room_name_label mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.mas_equalTo(self.hotel_room_image_view.mas_right).mas_offset(k_hotel_info_cell_lr_in_space);
        make.top.mas_equalTo(k_hotel_info_cell_tb_space);
        make.height.mas_equalTo(label_h);
        make.right.mas_equalTo(-k_hotel_info_cell_lr_out_space);
    }];
    
    [self.hotel_room_info_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.hotel_room_name_label.mas_left);
    make.top.mas_equalTo(self.hotel_room_name_label.mas_bottom).mas_offset(k_hotel_info_cell_lr_in_space);
        make.height.mas_equalTo(label_h);
        make.right.mas_equalTo(-k_hotel_info_cell_lr_out_space);
    }];
    
    [self.hotel_room_remark_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.hotel_room_name_label.mas_left);
        make.top.mas_equalTo(self.hotel_room_info_label.mas_bottom).mas_offset(2);
        make.height.mas_equalTo(label_h);
    make.right.mas_equalTo(self.hotel_room_reserve_button.mas_left);
    }];
    
    [self.hotel_room_price_label mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.hotel_room_name_label.mas_left);
    make.bottom.mas_equalTo(self.hotel_room_image_view.mas_bottom).mas_offset(3);
        make.height.mas_equalTo(label_h * 1.6);
    make.right.mas_equalTo(self.hotel_room_reserve_button.mas_left);
    }];
    
    [self.hotel_room_reserve_button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-k_hotel_info_cell_lr_out_space);
    make.bottom.mas_equalTo(self.hotel_room_price_label.mas_bottom);
        make.height.mas_equalTo(k_hotel_room_image_view_h * 0.30);
        make.width.mas_equalTo(53);
    }];
    
   
}

-(UIImageView *)hotel_room_image_view{
    
    if (_hotel_room_image_view == nil) {
        _hotel_room_image_view = [[UIImageView alloc] init];
        _hotel_room_image_view.layer.masksToBounds = YES;
        _hotel_room_image_view.layer.cornerRadius = 3;
        _hotel_room_image_view.backgroundColor =  RGB(219, 52, 52);
    }
    return _hotel_room_image_view;
}

-(UILabel *)hotel_room_name_label{
    
    if (_hotel_room_name_label == nil) {
        _hotel_room_name_label = [[UILabel alloc] init];
        _hotel_room_name_label.text = @"标准双人间A";
        _hotel_room_name_label.font = [UIFont systemFontOfSize:14.0f];
        _hotel_room_name_label.textColor = RGB(51, 51, 51);
        _hotel_room_name_label.textAlignment = NSTextAlignmentLeft;
        
    }
    return _hotel_room_name_label;
}

-(UILabel *)hotel_room_info_label{
    
    if (_hotel_room_info_label == nil) {
        _hotel_room_info_label = [[UILabel alloc] init];
        _hotel_room_info_label.text = @"含早|28m|单人床|有窗";
        _hotel_room_info_label.font = [UIFont systemFontOfSize:12.0f];
        _hotel_room_info_label.textColor = RGB(163, 163, 163);
        _hotel_room_info_label.textAlignment = NSTextAlignmentLeft;
        
    }
    return _hotel_room_info_label;
}

-(UILabel *)hotel_room_remark_label{
    
    if (_hotel_room_remark_label == nil) {
        _hotel_room_remark_label = [[UILabel alloc] init];
        _hotel_room_remark_label.text = @"入住当天6点前可取消";
        _hotel_room_remark_label.font = [UIFont systemFontOfSize:11.0f];
        _hotel_room_remark_label.textColor = RGB(231, 157, 58);
        _hotel_room_remark_label.textAlignment = NSTextAlignmentLeft;
        
    }
    return _hotel_room_remark_label;
}

-(UILabel *)hotel_room_price_label{
    
    if (_hotel_room_price_label == nil) {
        _hotel_room_price_label = [[UILabel alloc] init];
        _hotel_room_price_label.text = @"￥188";
        _hotel_room_price_label.textAlignment = NSTextAlignmentLeft;
        _hotel_room_price_label.font = [UIFont systemFontOfSize:18.0f];
        _hotel_room_price_label.textColor = RGB(219, 52, 52);
    }
    return _hotel_room_price_label;
}

-(UIButton *)hotel_room_reserve_button{
    
    if (_hotel_room_reserve_button == nil) {
        _hotel_room_reserve_button = [[UIButton alloc] init];
        _hotel_room_reserve_button.layer.masksToBounds = YES;
        _hotel_room_reserve_button.layer.cornerRadius = 16;
        _hotel_room_reserve_button.titleLabel.font = [UIFont systemFontOfSize:14];
        [_hotel_room_reserve_button setBackgroundColor:RGB(231, 157, 58)];
        [_hotel_room_reserve_button setTitle:@"预定" forState:UIControlStateNormal];
        [_hotel_room_reserve_button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
    }
    return _hotel_room_reserve_button;
}

/*
 * 评价
 */
-(void)createSCHotelEvaluateView{
   
    [self.contentView addSubview:self.hotel_evaluate_image_view];
    [self.contentView addSubview:self.hotel_evaluate_nema_label];
    [self.contentView addSubview:self.hotel_evaluate_room_label];
    [self.contentView addSubview:self.hotel_evaluate_timer_label];
    [self.contentView addSubview:self.hotel_evaluate_info_label];
  
    CGSize hotel_evaluate_nema_label_size = [self.hotel_evaluate_nema_label.text sizeWithAttributes:@{NSFontAttributeName:self.hotel_evaluate_nema_label.font}];
    CGSize hotel_evaluate_room_label_size = [self.hotel_evaluate_room_label.text sizeWithAttributes:@{NSFontAttributeName:self.hotel_evaluate_room_label.font}];
    CGFloat hotel_evaluate_nema_label_w = hotel_evaluate_nema_label_size.width + 10;
    CGFloat hotel_evaluate_room_label_w = hotel_evaluate_room_label_size.width + 10;
    
    CGFloat hotel_evaluate_nema_label_h = k_hotel_evaluate_image_view_h * 0.35;
    CGFloat hotel_evaluate_info_label_h = k_hotel_evaluate_image_view_h * 0.65;
   
    [self.hotel_evaluate_image_view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo((k_hotel_evaluate_cell_h - k_hotel_evaluate_image_view_h) * 0.5);
        make.height.mas_equalTo(k_hotel_evaluate_image_view_h);
        make.width.mas_equalTo(k_hotel_evaluate_image_view_h);
        make.left.mas_equalTo(k_hotel_info_cell_lr_out_space);
    }];
    
    [self.hotel_evaluate_nema_label mas_makeConstraints:^(MASConstraintMaker *make) {
    
        make.top.mas_equalTo(self.hotel_evaluate_image_view.mas_top);
        make.height.mas_equalTo(hotel_evaluate_nema_label_h);
        make.width.mas_equalTo(hotel_evaluate_nema_label_w);
    make.left.mas_equalTo(self.hotel_evaluate_image_view.mas_right).mas_offset(k_hotel_info_cell_lr_in_space);
    }];
    
    [self.hotel_evaluate_room_label mas_makeConstraints:^(MASConstraintMaker *make) {
       make.top.mas_equalTo(self.hotel_evaluate_image_view.mas_top);
        make.height.mas_equalTo(hotel_evaluate_nema_label_h);
        make.width.mas_equalTo(hotel_evaluate_room_label_w);
    make.left.mas_equalTo(self.hotel_evaluate_nema_label.mas_right);
    }];
    
    [self.hotel_evaluate_timer_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.hotel_evaluate_image_view.mas_top).mas_offset(2);
        make.height.mas_equalTo(hotel_evaluate_nema_label_h - 3);
        make.right.mas_equalTo(-k_hotel_info_cell_lr_out_space);
        make.width.mas_equalTo(70);
    }];
    
    [self.hotel_evaluate_info_label mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.mas_equalTo(self.hotel_evaluate_nema_label.mas_bottom).mas_offset(4);
        make.height.mas_equalTo(hotel_evaluate_info_label_h);
        make.right.mas_equalTo(-k_hotel_info_cell_lr_out_space);
    make.left.mas_equalTo(self.hotel_evaluate_image_view.mas_right).mas_offset(k_hotel_info_cell_lr_in_space);
    }];
    
}

-(UIImageView *)hotel_evaluate_image_view{
    
    if (_hotel_evaluate_image_view == nil) {
        _hotel_evaluate_image_view = [[UIImageView alloc] init];
        _hotel_evaluate_image_view.layer.masksToBounds = YES;
        _hotel_evaluate_image_view.layer.cornerRadius = 19;
        _hotel_evaluate_image_view.backgroundColor =  RGB(219, 52, 52);
    }
    return _hotel_evaluate_image_view;
}

-(UILabel *)hotel_evaluate_nema_label{
    
    if (_hotel_evaluate_nema_label == nil) {
        _hotel_evaluate_nema_label = [[UILabel alloc] init];
        _hotel_evaluate_nema_label.text = @"用户昵称";
        _hotel_evaluate_nema_label.font = [UIFont systemFontOfSize:12.0f];
        _hotel_evaluate_nema_label.textColor = RGB(51, 51, 51);
        _hotel_evaluate_nema_label.textAlignment = NSTextAlignmentLeft;
        
    }
    return _hotel_evaluate_nema_label;
}

-(UILabel *)hotel_evaluate_room_label{
    
    if (_hotel_evaluate_room_label == nil) {
        _hotel_evaluate_room_label = [[UILabel alloc] init];
        _hotel_evaluate_room_label.text = @"特价标间";
        _hotel_evaluate_room_label.font = [UIFont systemFontOfSize:12.0f];
        _hotel_evaluate_room_label.textColor = RGB(163, 163, 163);
        _hotel_evaluate_room_label.textAlignment = NSTextAlignmentLeft;
        
    }
    return _hotel_evaluate_room_label;
}

-(UILabel *)hotel_evaluate_timer_label{
    
    if (_hotel_evaluate_timer_label == nil) {
        _hotel_evaluate_timer_label = [[UILabel alloc] init];
        _hotel_evaluate_timer_label.text = @"2019-04-23";
        _hotel_evaluate_timer_label.font = [UIFont systemFontOfSize:10.0f];
        _hotel_evaluate_timer_label.textColor = RGB(206, 206, 206);
        _hotel_evaluate_timer_label.textAlignment = NSTextAlignmentRight;
        
    }
    return _hotel_evaluate_timer_label;
}

-(UILabel *)hotel_evaluate_info_label{
    
    if (_hotel_evaluate_info_label == nil) {
        _hotel_evaluate_info_label = [[UILabel alloc] init];
        _hotel_evaluate_info_label.text = @"综合来讲还不错，综合来讲还不错，综合来讲还不错，综合来讲还不错，综合来讲还不错";
        _hotel_evaluate_info_label.font = [UIFont systemFontOfSize:12.0f];
        _hotel_evaluate_info_label.textColor = RGB(51, 51, 51);
        _hotel_evaluate_info_label.textAlignment = NSTextAlignmentLeft;
      
        
    }
    return _hotel_evaluate_info_label;
}


/*
 * 酒店设置
 */
-(void)createSCHotelSeteView{
    
}

/*
 * 入住须知
 */
-(void)createSCHotelNoticeView{
    
    self.hotel_notice_view = [[SCHotelNoticeView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, k_hotel_notice_cell_h)];
    self.hotel_notice_view.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.hotel_notice_view];
    
}

-(void)setHotel_notice_array:(NSMutableArray *)hotel_notice_array{
    
    [self.hotel_notice_view setHotel_notice_array:hotel_notice_array];
    
}

/*
 * 入住须知图片
 */
-(void)createSCHotelNoticeImageView{
    
    [self.contentView addSubview:self.hotel_notice_image_view];
}

-(UIImageView *)hotel_notice_image_view{
    
    if (_hotel_notice_image_view == nil) {
        _hotel_notice_image_view = [[UIImageView alloc] initWithFrame:CGRectMake(k_hotel_info_cell_lr_out_space, 0, kScreenW - k_hotel_info_cell_lr_out_space * 2, k_hotel_notice_img_cell_h)];
        _hotel_notice_image_view.backgroundColor =  RGB(219, 52, 52);
    }
    return _hotel_notice_image_view;
}

@end
